﻿
using System;
using System.Data;
using System.Collections.Generic;

namespace LDSP.BRL
{
    public partial class R_EnterpriseCatalog : BYFW.BOL.BaseEntity
    {
        public R_EnterpriseCatalog()
        {
            m_tableName = "t_r_enterprise_catalog";
            m_tblCacheManager.IsEnable = true;
            m_objCacheManager.Size = 1000;
        }

        protected int m_enterpriseID = 0;
        protected int m_catalogID = 0;
        protected Enterprise m_enterprise = null;
        protected Catalog m_catalog = null;

        /// <summary>
        /// 
        /// </summary>
        public int EnterpriseID
        {
            get { return m_enterpriseID; }
            set { m_enterpriseID = value; }
        }
        /// <summary>
        /// 
        /// </summary>
        public int CatalogID
        {
            get { return m_catalogID; }
            set { m_catalogID = value; }
        }

        public Enterprise Enterprise
        {
            get
            {
                if (m_enterprise == null)
                {
                    m_enterprise = new Enterprise();
                    if (m_enterpriseID != 0)
                    {
                        m_enterprise.GetProperties(m_enterpriseID);
                    }
                }
                return m_enterprise;
            }
        }

        public Catalog Catalog
        {
            get
            {
                if (m_catalog == null)
                {
                    m_catalog = new Catalog();
                    if (m_catalogID != 0)
                    {
                        m_catalog.GetProperties(m_catalogID);
                    }
                }
                return m_catalog;
            }
        }

        protected override void FillContainer()
        {
            base.FillContainer();
            m_container.Add("enterpriseID", m_enterpriseID);
            m_container.Add("catalogID", m_catalogID);
        }

        public override bool GetProperties(System.Data.DataRow record)
        {
            if (!base.GetProperties(record))
            {
                return false;
            }
            m_enterpriseID = this.GetIntValue(record, "enterpriseID");
            m_catalogID = this.GetIntValue(record, "catalogID");
            return true;
        }

        public List<R_EnterpriseCatalog> GetListByEnterpriseID(int enterpriseID)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("enterpriseID"), DB.GetVal(enterpriseID));
            return this.GetSpecialList<R_EnterpriseCatalog>(null, cond);
        }

        public void DeleteByEnterpriseID(int enterpriseID)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("enterpriseID"), DB.GetVal(enterpriseID));
            this.DeleteRecord(null, cond);
        }

        public void DeleteByCatalogID(int catalogID)
        {
            string cond = string.Format("where {0}={1}", DB.GetCol("catalogID"), DB.GetVal(catalogID));
            this.DeleteRecord(null, cond);
        }
    }
}
